﻿namespace HRM.CORE.Workdesk
{
    using DevExpress.XtraEditors;
    using APP.HELPER;
    using Extra;

    using HRM.CORE;
    using HRM.CORE.Properties;
    
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms; using Common;
    using Extra.ERP;
    using Security.ERP;
    using Extra.Data.Extra.Class;
    using APP.HELPER.Data.Helper;
    using APP.HELPER.Utils.Language;
    using Extra.Data.Extra.Forms;
    using Extra.Data.Core;

    public class xucUser : Common.xucBase
    {
        private IContainer components = null;
        private GroupControl groupControl1;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private LabelControl labelControl3;
        private LabelControl labelControl4;
        private LabelControl labelControl6;
        private LabelControl lblAccount;
        private LabelControl lblDatabase;
        private LabelControl lblDate;
        private LabelControl lblPermision;
        private LabelControl lblServer;
        private LinkLabel linkLabel2;
        private LinkLabel llBackup;
        private LinkLabel llChangePassword;
        private LinkLabel llRestore;
        private PictureBox pictureBox1;
        private PictureBox pictureBox2;
        private PictureBox pictureBox3;
        private PictureBox pictureBox4;
        private PictureBox pictureBox5;
        private SplitContainerControl splitContainerControl1;

        public xucUser()
        {
            this.InitializeComponent();
            this.InitMultiLanguages();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xucUser));
            this.groupControl1 = new GroupControl();
            this.splitContainerControl1 = new SplitContainerControl();
            this.labelControl6 = new LabelControl();
            this.lblDatabase = new LabelControl();
            this.llRestore = new LinkLabel();
            this.pictureBox4 = new PictureBox();
            this.pictureBox5 = new PictureBox();
            this.llBackup = new LinkLabel();
            this.labelControl4 = new LabelControl();
            this.lblServer = new LabelControl();
            this.linkLabel2 = new LinkLabel();
            this.labelControl1 = new LabelControl();
            this.lblAccount = new LabelControl();
            this.pictureBox1 = new PictureBox();
            this.lblDate = new LabelControl();
            this.pictureBox2 = new PictureBox();
            this.labelControl2 = new LabelControl();
            this.lblPermision = new LabelControl();
            this.pictureBox3 = new PictureBox();
            this.llChangePassword = new LinkLabel();
            this.labelControl3 = new LabelControl();
            this.groupControl1.BeginInit();
            this.groupControl1.SuspendLayout();
            this.splitContainerControl1.BeginInit();
            this.splitContainerControl1.SuspendLayout();
            ((ISupportInitialize) this.pictureBox4).BeginInit();
            ((ISupportInitialize) this.pictureBox5).BeginInit();
            ((ISupportInitialize) this.pictureBox1).BeginInit();
            ((ISupportInitialize) this.pictureBox2).BeginInit();
            ((ISupportInitialize) this.pictureBox3).BeginInit();
            base.SuspendLayout();
            this.groupControl1.Controls.Add(this.splitContainerControl1);
            this.groupControl1.Dock = DockStyle.Fill;
            this.groupControl1.Location = new Point(0, 0);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Padding = new Padding(4);
            this.groupControl1.Size = new Size(0x36b, 0xa9);
            this.groupControl1.TabIndex = 0;
            this.groupControl1.Text = "Cấu H\x00ecnh Dữ Liệu - T\x00e0i Khoản Người D\x00f9ng";
            this.splitContainerControl1.Dock = DockStyle.Fill;
            this.splitContainerControl1.Location = new Point(6, 0x1a);
            this.splitContainerControl1.Name = "splitContainerControl1";
            this.splitContainerControl1.Panel1.Controls.Add(this.labelControl6);
            this.splitContainerControl1.Panel1.Controls.Add(this.lblDatabase);
            this.splitContainerControl1.Panel1.Controls.Add(this.llRestore);
            this.splitContainerControl1.Panel1.Controls.Add(this.pictureBox4);
            this.splitContainerControl1.Panel1.Controls.Add(this.pictureBox5);
            this.splitContainerControl1.Panel1.Controls.Add(this.llBackup);
            this.splitContainerControl1.Panel1.Controls.Add(this.labelControl4);
            this.splitContainerControl1.Panel1.Controls.Add(this.lblServer);
            this.splitContainerControl1.Panel1.Controls.Add(this.linkLabel2);
            this.splitContainerControl1.Panel1.Text = "Panel1";
            this.splitContainerControl1.Panel2.Controls.Add(this.labelControl1);
            this.splitContainerControl1.Panel2.Controls.Add(this.lblAccount);
            this.splitContainerControl1.Panel2.Controls.Add(this.pictureBox1);
            this.splitContainerControl1.Panel2.Controls.Add(this.lblDate);
            this.splitContainerControl1.Panel2.Controls.Add(this.pictureBox2);
            this.splitContainerControl1.Panel2.Controls.Add(this.labelControl2);
            this.splitContainerControl1.Panel2.Controls.Add(this.lblPermision);
            this.splitContainerControl1.Panel2.Controls.Add(this.pictureBox3);
            this.splitContainerControl1.Panel2.Controls.Add(this.llChangePassword);
            this.splitContainerControl1.Panel2.Controls.Add(this.labelControl3);
            this.splitContainerControl1.Panel2.Text = "Panel2";
            this.splitContainerControl1.Size = new Size(0x35f, 0x89);
            this.splitContainerControl1.SplitterPosition = 320;
            this.splitContainerControl1.TabIndex = 0x12;
            this.splitContainerControl1.Text = "splitContainerControl1";
            this.labelControl6.Location = new Point(0x2c, 13);
            this.labelControl6.Name = "labelControl6";
            this.labelControl6.Size = new Size(0x6c, 13);
            this.labelControl6.TabIndex = 13;
            this.labelControl6.Text = "T\x00ean m\x00e1y chủ (Server):";
            this.lblDatabase.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.lblDatabase.Appearance.Options.UseFont = true;
            this.lblDatabase.Location = new Point(0xa9, 0x2f);
            this.lblDatabase.Name = "lblDatabase";
            this.lblDatabase.Size = new Size(0x43, 13);
            this.lblDatabase.TabIndex = 15;
            this.lblDatabase.Text = "lblDatabase";
            this.llRestore.AutoSize = true;
            this.llRestore.Location = new Point(4, 0x5f);
            this.llRestore.Name = "llRestore";
            this.llRestore.Size = new Size(180, 13);
            this.llRestore.TabIndex = 20;
            this.llRestore.TabStop = true;
            this.llRestore.Text = "Phục hồi dữ liệu (Restore Database)";
            this.llRestore.LinkClicked += new LinkLabelLinkClickedEventHandler(this.llRestore_LinkClicked);
            this.pictureBox4.Image = (Image) manager.GetObject("pictureBox4.Image");
            this.pictureBox4.Location = new Point(6, 0x2f);
            this.pictureBox4.Name = "pictureBox4";
            this.pictureBox4.Size = new Size(15, 13);
            this.pictureBox4.TabIndex = 14;
            this.pictureBox4.TabStop = false;
            this.pictureBox5.Image = Resources.database_icon;
            this.pictureBox5.Location = new Point(6, 3);
            this.pictureBox5.Name = "pictureBox5";
            this.pictureBox5.Size = new Size(0x20, 0x20);
            this.pictureBox5.SizeMode = PictureBoxSizeMode.Zoom;
            this.pictureBox5.TabIndex = 11;
            this.pictureBox5.TabStop = false;
            this.llBackup.AutoSize = true;
            this.llBackup.Location = new Point(4, 0x48);
            this.llBackup.Name = "llBackup";
            this.llBackup.Size = new Size(0xac, 13);
            this.llBackup.TabIndex = 0x13;
            this.llBackup.TabStop = true;
            this.llBackup.Text = "Sao lưu dữ liệu (Backup Database)";
            this.llBackup.LinkClicked += new LinkLabelLinkClickedEventHandler(this.llBackup_LinkClicked);
            this.labelControl4.Location = new Point(0x15, 0x2f);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new Size(0x8e, 13);
            this.labelControl4.TabIndex = 0x10;
            this.labelControl4.Text = "T\x00ean cơ sở dữ liệu (Database):";
            this.lblServer.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.lblServer.Appearance.Options.UseFont = true;
            this.lblServer.Location = new Point(0x9b, 13);
            this.lblServer.Name = "lblServer";
            this.lblServer.Size = new Size(0x33, 13);
            this.lblServer.TabIndex = 12;
            this.lblServer.Text = "lblServer";
            this.linkLabel2.AutoSize = true;
            this.linkLabel2.Location = new Point(4, 0x76);
            this.linkLabel2.Name = "linkLabel2";
            this.linkLabel2.Size = new Size(0xdb, 13);
            this.linkLabel2.TabIndex = 0x11;
            this.linkLabel2.TabStop = true;
            this.linkLabel2.Text = "Khởi động chương tr\x00ecnh quản l\x00fd cơ sở dữ liệu";
            this.linkLabel2.LinkClicked += new LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);
            this.labelControl1.Location = new Point(0x2e, 13);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x95, 13);
            this.labelControl1.TabIndex = 4;
            this.labelControl1.Text = "T\x00ean người d\x00f9ng (User's Name):";
            this.lblAccount.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.lblAccount.Appearance.Options.UseFont = true;
            this.lblAccount.Location = new Point(0xcb, 13);
            this.lblAccount.Name = "lblAccount";
            this.lblAccount.Size = new Size(0x3b, 13);
            this.lblAccount.TabIndex = 1;
            this.lblAccount.Text = "lblAccount";
            this.pictureBox1.Image = Resources.Person;
            this.pictureBox1.Location = new Point(8, 3);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new Size(0x20, 0x20);
            this.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
            this.pictureBox1.TabIndex = 0;
            this.pictureBox1.TabStop = false;
            this.lblDate.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.lblDate.Appearance.Options.UseFont = true;
            this.lblDate.Location = new Point(0x6c, 0x48);
            this.lblDate.Name = "lblDate";
            this.lblDate.Size = new Size(40, 13);
            this.lblDate.TabIndex = 3;
            this.lblDate.Text = "lblDate";
            this.pictureBox2.Image = (Image) manager.GetObject("pictureBox2.Image");
            this.pictureBox2.Location = new Point(7, 0x49);
            this.pictureBox2.Name = "pictureBox2";
            this.pictureBox2.Size = new Size(15, 13);
            this.pictureBox2.TabIndex = 2;
            this.pictureBox2.TabStop = false;
            this.labelControl2.Location = new Point(0x16, 0x48);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x53, 13);
            this.labelControl2.TabIndex = 5;
            this.labelControl2.Text = "Ng\x00e0y đăng nhập:";
            this.lblPermision.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.lblPermision.Appearance.Options.UseFont = true;
            this.lblPermision.Location = new Point(0x40, 0x2e);
            this.lblPermision.Name = "lblPermision";
            this.lblPermision.Size = new Size(0x45, 13);
            this.lblPermision.TabIndex = 7;
            this.lblPermision.Text = "lblPermision";
            this.pictureBox3.Image = (Image) manager.GetObject("pictureBox3.Image");
            this.pictureBox3.Location = new Point(8, 0x2f);
            this.pictureBox3.Name = "pictureBox3";
            this.pictureBox3.Size = new Size(15, 13);
            this.pictureBox3.TabIndex = 6;
            this.pictureBox3.TabStop = false;
            this.llChangePassword.AutoSize = true;
            this.llChangePassword.Location = new Point(5, 0x75);
            this.llChangePassword.Name = "llChangePassword";
            this.llChangePassword.Size = new Size(0x5f, 13);
            this.llChangePassword.TabIndex = 10;
            this.llChangePassword.TabStop = true;
            this.llChangePassword.Text = "Thay đổi mật khẩu";
            this.llChangePassword.LinkClicked += new LinkLabelLinkClickedEventHandler(this.llChangePassword_LinkClicked);
            this.labelControl3.Location = new Point(0x17, 0x2e);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x23, 13);
            this.labelControl3.TabIndex = 8;
            this.labelControl3.Text = "Vai tr\x00f2:";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.groupControl1);
            base.Name = "xucUser";
            base.Size = new Size(0x36b, 0xa9);
            this.groupControl1.EndInit();
            this.groupControl1.ResumeLayout(false);
            this.splitContainerControl1.EndInit();
            this.splitContainerControl1.ResumeLayout(false);
            ((ISupportInitialize) this.pictureBox4).EndInit();
            ((ISupportInitialize) this.pictureBox5).EndInit();
            ((ISupportInitialize) this.pictureBox1).EndInit();
            ((ISupportInitialize) this.pictureBox2).EndInit();
            ((ISupportInitialize) this.pictureBox3).EndInit();
            base.ResumeLayout(false);
        }

        private void InitMultiLanguages()
        {
            this.groupControl1.Text = MultiLanguages.GetString("tbl_DashBoard", "ConfigurationDatabase", "Cấu H\x00ecnh Dữ Liệu") + " - " + MultiLanguages.GetString("tbl_DashBoard", "UserAccount", "T\x00e0i Khoản Người D\x00f9ng");
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            this.lblServer.Enabled = false;
            if (File.Exists(Application.StartupPath + @"\Perfect.Data.exe"))
            {
                Process.Start(Application.StartupPath + @"\Perfect.Data.exe");
            }
            this.lblServer.Enabled = true;
            Cursor.Current = Cursors.Default;
        }

        private void llBackup_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            new XfmBackupDatabase().ShowDialog();
        }

        private void llChangePassword_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            new frmChangePassword().ShowDialog();
        }

        private void llRestore_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            new xfmRestoreDatabase().ShowDialog();
        }

        public void LoadData()
        {
            SqlHelper helper = new SqlHelper(SqlHelper.ConnectString);
            helper.Extract();
            this.lblServer.Text = helper.Server;
            this.lblDatabase.Text = helper.Database + " (" + DbInfo.CurrentVersion + ")";
            SYS_GROUP sys_group = new SYS_GROUP();
            sys_group.Get(MyLogin.RoleId);
            this.lblAccount.Text = MyLogin.Account;
            this.lblPermision.Text = sys_group.Group_Name;
            this.lblDate.Text = MyLogin.LoginDate.ToShortDateString();
        }
    }
}

